package com.tjx.controller;


import com.tjx.common.Result;
import com.tjx.entity.PackageDetail;
import com.tjx.entity.Ticket;
import com.tjx.service.IPackageDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 套餐详情表：仅保留自增主键，无其他索引和约束 前端控制器
 * </p>
 *
 * @author tjx
 * @since 2025-10-29
 */
@RestController
@RequestMapping("/package-detail")
public class PackageDetailController {
    @Autowired
    IPackageDetailService packageDetailService;

    // 查询一个套餐详情服务
    @RequestMapping("/getPackageDetailByPackageId")
    public Result<List<Ticket>> getPackageDetailByPackageId(@RequestBody PackageDetail packageDetail) {
        // 校验套餐id是否为空
        if (packageDetail.getPackageId() == null) {
            return Result.fail("套餐id不能为空",null);
        }
        // 调用服务层查询套餐详情
        List<Ticket> tickets = packageDetailService.getPackageDetailByPackageId(packageDetail);
        if (tickets == null || tickets.isEmpty()) {
            return Result.fail("未找到该套餐的详情记录",null);
        }
//        List<Ticket> tickets1 = packageDetailService.getPackageDetailByUserId(packageDetail);
        return Result.ok(tickets);
    }
}
